package com.hmall.item.Interceptor;

import com.hmall.item.utils.MyThreadLoacl;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description MyHandlerInterceptor
 * @Author GGBond
 * @Date 2024-11-16
 */

@Component
public class MyHandlerInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String token = request.getHeader("authorization");
        MyThreadLoacl.setSubject(token);
        return true;
    }
}
